package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("添加图书");
        Book book = new Book();
        int usedSize = bookList.getUsedSize();
        Scanner sc = new Scanner(System.in);

        System.out.println("请输入图书的名字");
        String name = sc.nextLine();
        book.setName(name);

        System.out.println("请输入图书的作者");
        String author = sc.nextLine();
        book.setAuthor(author);

        System.out.println("请输入图书的类型");
        String type = sc.nextLine();;
        book.setType(type);

        System.out.println("请输入图书的价格");
        double price = sc.nextDouble();
        book.setPrice(price);

        bookList.setBooks(usedSize,book);
        bookList.setUsedSize(usedSize+1);

        System.out.println("新增成功!");
    }
}
